import java.io.*;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-10-28
 * Time: 18:16
 */
public class practice2 {
    public static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) throws IOException {
        System.out.println("请输入源文件地址");
        File src = new File(scanner.next());
        if(!src.isFile()) {
            System.out.println("您输入的源文件地址不合法！");
        }
        System.out.println("请输入目标文件地址");
        File dest = new File(scanner.next());
        if(!dest.getParentFile().isDirectory()) {
            System.out.println("您输入的目标文件地址不合法");
        }

        try (InputStream inputStream = new FileInputStream(src);
             OutputStream outputStream = new FileOutputStream(dest)) {
            while (true) {
                byte[] buf = new byte[10280];
                int n = inputStream.read(buf);
                System.out.println("读到的字节个数为：" + n);
                if(n == -1 ) {
                    System.out.println("读取到eof，循环结束！");
                    break;
                }
                outputStream.write(buf, 0, n);
            }
        }
    }
}
